package org.brave.mybatis.service;

import org.brave.mybatis.mapper.BaseMapper;

import java.io.Serializable;
import java.util.List;

/**
 * @author zhanghn
 * @since 2025/01/10
 */
public class BaseServiceImpl<PK extends Serializable, T> implements BaseService<PK, T> {
    private BaseMapper<PK, T> baseMapper;

    @Override
    public List<T> listAll() {
        return baseMapper.selectAll();
    }

    @Override
    public T getById(PK id) {
        return baseMapper.selectById(id);
    }

    @Override
    public int save(T entity) {
        return baseMapper.insert(entity);
    }

    @Override
    public int updateById(T entity) {
        return baseMapper.update(entity);
    }

    @Override
    public int deleteById(PK id) {
        return baseMapper.deleteById(id);
    }
}
